package cn.yikaojiuguo.student.ui.usercenter;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.GridView;

import java.util.Arrays;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.yikaojiuguo.student.R;
import cn.yikaojiuguo.student.adapter.ChooseGradeAdapter;
import cn.yikaojiuguo.student.app.YiKaoApplication;
import cn.yikaojiuguo.student.ui.base.CustomerActionBarActivity;

public class ChooseGradeActivity extends CustomerActionBarActivity implements View.OnClickListener{

    @Bind(R.id.gv)
    GridView mGv;
    private List<String> mList;
    private int mChooseMajor = -1;

    public static Intent newIntent() {
        Intent intent = new Intent(YiKaoApplication.getInstance(),ChooseGradeActivity.class);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choose_grade);
        ButterKnife.bind(this);
        mList = Arrays.asList(getResources().getStringArray(R.array.grade));
        mChooseMajor = YiKaoApplication.getChooseGradeIndex();
        ChooseGradeAdapter adapter = new ChooseGradeAdapter(this,mList,mChooseMajor);
        mGv.setAdapter(adapter);
        setCustomerBackOnclickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                startActivity(ChooseMajorActivity.newIntent());
                leftEnter();
                finish();
                break;
        }
    }

    @Override
    public void onBackPressed() {
        mIv_back.performClick();
    }
}
